﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using System.Data.SQLite;

namespace Service
{
    public class VisitadorSvr
    {
        #region Propiedades
        Data.Configuration.Context _Context = new Data.Configuration.Context();
        SQLiteConnection _Conn = new Data.Configuration.Context().GetNewDatabaseConnection();
        #endregion
        public bool checkUser(string Username, string Pass)
        {
            Visitante v = new Visitante(this._Conn);
            v.Load(Username);
            if (v.Simple == null)
            {
                SimpleVisitante sv = new SimpleVisitante();
                sv.UserName = Username;
                sv.Password = Pass;
                sv.FullName = Username;
                sv.FechaIngreso = DateTime.Now;
                v = new Visitante(sv, this._Conn);
                v.Insert();
                return true;
            }
            else
            {
                if (String.Equals(v.Simple.Password, Pass))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

        }
    }
}
